package hn.sigit.model.ladm.administrative;

import java.io.Serializable;
import javax.persistence.*;
@Entity
@org.hibernate.annotations.Proxy(lazy=false)
@Table(name="LA_RequiredRelationshipBAUnit", schema="ladm_administrative")
@Inheritance(strategy=InheritanceType.JOINED)
@IdClass(LA_RequiredRelationshipBAUnitPK.class)
public class LA_RequiredRelationshipBAUnit extends hn.sigit.model.ladm.special.VersionedObject implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private long baunits2La_baunitId;
	private long baunits1La_baunitId;
	private String relationship;
	private LA_BAUnit baunits2La_baunit;
	private LA_BAUnit baunits1La_baunit;

	public LA_RequiredRelationshipBAUnit() {
	}
	
	
	@Id
	@Column(name="LA_BAUnitID", nullable=false)
	@GeneratedValue(generator="la_requiredrelationshipbaunit_gen")
	@org.hibernate.annotations.GenericGenerator(name="la_requiredrelationshipbaunit_gen", strategy="foreign", parameters=@org.hibernate.annotations.Parameter(name="property", value="Id"))
	public long getBaunits2La_baunitId() {
		return baunits2La_baunitId;
	}
	protected void setBaunits2La_baunitId(long value) {
		this.baunits2La_baunitId = value;
	}
	
	@Id
	@Column(name="LA_BAUnitID2", nullable=false)
	@GeneratedValue(generator="la_requiredrelationshipbaunit_gen2")
	@org.hibernate.annotations.GenericGenerator(name="la_requiredrelationshipbaunit_gen2", strategy="foreign", parameters=@org.hibernate.annotations.Parameter(name="property", value="Id"))
	public long getBaunits1La_baunitId() {
		return baunits1La_baunitId;
	}
	protected void setBaunits1La_baunitId(long value) {
		this.baunits1La_baunitId = value;
	}
	
	@Column(name="Relationship", nullable=true, length=255)
	public String getRelationship() {
		return relationship;
	}
	public void setRelationship(String value) {
		this.relationship = value;
	}
	
	@PrimaryKeyJoinColumn
	@ManyToOne(targetEntity=LA_BAUnit.class)
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})
	@JoinColumns({ @JoinColumn(name="LA_BAUnitID2", referencedColumnName="ID") })
	public LA_BAUnit getBaunits1La_baunit() {
		return baunits1La_baunit;
	}
	public void setBaunits1La_baunit(LA_BAUnit value) {
		this.baunits1La_baunit = value;
	}
	
	@PrimaryKeyJoinColumn
	@ManyToOne(targetEntity=LA_BAUnit.class)
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})
	@JoinColumns({ @JoinColumn(name="LA_BAUnitID", referencedColumnName="ID") })
	public LA_BAUnit getBaunits2La_baunit() {
		return baunits2La_baunit;
	}
	public void setBaunits2La_baunit(LA_BAUnit value) {
		this.baunits2La_baunit = value;
	}
	
	
	
	public boolean equals(Object aObj) {
		if (aObj == this)
			return true;
		if (!(aObj instanceof LA_RequiredRelationshipBAUnit))
			return false;
		LA_RequiredRelationshipBAUnit la_requiredrelationshipbaunit = (LA_RequiredRelationshipBAUnit)aObj;
		if (getBaunits2La_baunit() == null) {
			if (la_requiredrelationshipbaunit.getBaunits2La_baunit() != null)
				return false;
		}
		else if (!getBaunits2La_baunit().equals(la_requiredrelationshipbaunit.getBaunits2La_baunit()))
			return false;
		if (getBaunits1La_baunit() == null) {
			if (la_requiredrelationshipbaunit.getBaunits1La_baunit() != null)
				return false;
		}
		else if (!getBaunits1La_baunit().equals(la_requiredrelationshipbaunit.getBaunits1La_baunit()))
			return false;
		return true;
	}
	
	public int hashCode() {
		int hashcode = 0;
		if (getBaunits2La_baunit() != null) {
			hashcode = hashcode + (int) getBaunits2La_baunit().getORMID();
		}
		if (getBaunits1La_baunit() != null) {
			hashcode = hashcode + (int) getBaunits1La_baunit().getORMID();
		}
		return hashcode;
	}
	
	public String toString() {
		return super.toString();
	}
	
	private boolean _saved = false;
	
	public void onSave() {
		_saved=true;
	}
	
	
	public void onLoad() {
		_saved=true;
	}
	
	
	@Transient
	public boolean isSaved() {
		return _saved;
	}
	
	
}
